<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link rel="stylesheet" href="/public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/public/css/login.css">
    <script src="/public/js/jquery.min.js"></script>
</head>
<body>
    
    <!-- axios：  使用ajax实现登录功能 -->
    <div class="aaa">
            <div class="tx">
                <img src="../public/imgs/头像.jpeg" alt="">
            </div>
            <div class="bbb">
              <label>账号：</label>
              <input type="text"   class="ccc" id="user" placeholder="账号">
            </div>
            <div class="ddd">
              <label>密码：</label>
              <input type="text"  class="eee" id="pass" placeholder="密码">
            </div>
            <button type="submit" class="btn btn-info">登录</button>
            <button type="submit" class="btn btn-info">注册</button>
    </div>
    
    
</body>
</html>
<script>
  $('.btn').click(function(){
      var user = $('#user').val();
      var pass = $('#pass').val();
      // console.log(user,pass);
      $.ajax({
          url:"/doLoginByAjax",
          data:{
              user,pass
          },
          type:"post",
          success(res){
              alert(res.msg)
              // console.log(res);
              if(res.code == 200){           
                  location.href="/index"
              }
          }
      })
  })
</script>